package com.wondertek.poms.dao.po;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.wondertek.poms.common.constant.CurrentUser;
import lombok.Data;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.Proxy;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 * <p><b>PcImageSrcRules Description:</b> PcImageSrcRules po类 ; 原图名称表 </p>
 * @author 窦再兴
 * <p><b>DATE</b> 2020-10-19 09:35:09</p>
 */
@Data
@Entity
@Table(name = "pc_image_src_rules")
@DynamicUpdate
@DynamicInsert
@Proxy(lazy = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class PcImageSrcRules implements java.io.Serializable {

	/**
	 * <b>Fields</b> serialVersionUID :
	 */
	private static final long serialVersionUID = -6905025556410658033L;

	/**
	 * <b>Fields</b> id : 主键ID
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "PC_IMAGE_SRC_RULES_SEQ")
	@SequenceGenerator(name = "PC_IMAGE_SRC_RULES_SEQ", allocationSize = 1, sequenceName = "PC_IMAGE_SRC_RULES_SEQ")
	private Long id;

	/**
	 * <b>Fields</b> srcRuleName : 原图规则名称
	 */
	@Column(name = "src_rule_name")
	private String srcRuleName;

	/**
	 * <b>Fields</b> srcRuleCode : 原图规则编码
	 */
	@Column(name = "src_rule_code")
	private String srcRuleCode;

	/**
	 * <b>Fields</b> createdBy : 创建人
	 */
	@Column(name = "created_by")
	private String createdBy;

	/**
	 * <b>Fields</b> createdTime : 创建时间
	 */
	@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@Column(name = "created_time")
	private java.time.LocalDateTime createdTime;

	/**
	 * <b>Fields</b> updatedBy : 更新人
	 */
	@Column(name = "updated_by")
	private String updatedBy;

	/**
	 * <b>Fields</b> updatedTime : 更新时间
	 */
	@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@Column(name = "updated_time")
	private java.time.LocalDateTime updatedTime;

	/**
	 * <b>Fields</b> deleted : 是否有效 0正常 1删除 2停用
	 */
	@Column(name = "DELETED")
	private Integer deleted = 0;

	public static void putTimeAndUser(PcImageSrcRules pcImageSrcRules) {
		if (pcImageSrcRules.id == null) {
			pcImageSrcRules.setCreatedBy(CurrentUser.currUserName());
			pcImageSrcRules.setCreatedTime(java.time.LocalDateTime.now());
		}
		pcImageSrcRules.setUpdatedBy(CurrentUser.currUserName());
		pcImageSrcRules.setUpdatedTime(java.time.LocalDateTime.now());
	}
}